#ifndef SDK_OHOS_OHOS_MEDIA_STREAM_H_
#define SDK_OHOS_OHOS_MEDIA_STREAM_H_

#include <string>
#include <vector>
#include "api/media_stream_interface.h"
#include "rtc_base/logging.h"
#include "rtc_base/thread.h"
#include "api/ohos_media_track_interface.h"
#include "api/ohos_media_stream_interface.h"
#include "api/ohos_audio_track_interface.h"
#include "api/ohos_video_track_interface.h"
#include "api/ohos_peer_connection_factory_interface.h"

namespace ohoswebrtc {

class OHOSMediaStream : public OHOSMediaStreamInterface {
  public:
    OHOSMediaStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> media_stream, rtc::scoped_refptr<OHOSPeerConnectionFactoryInterface> peer_connection_factory);

    virtual ~OHOSMediaStream();
    /** Adds the given audio track to this media stream. */
    void AddAudioTrack(rtc::scoped_refptr<OHOSAudioTrackInterface> track) override;
    /** Adds the given video track to this media stream. */
    void AddVideoTrack(rtc::scoped_refptr<OHOSVideoTrackInterface> track) override;
    /** Removes the given audio track to this media stream. */
    void RemoveAudioTrack(rtc::scoped_refptr<OHOSAudioTrackInterface> track) override;
    /** Removes the given video track to this media stream. */
    void RemoveVideoTrack(rtc::scoped_refptr<OHOSVideoTrackInterface> track) override;
    /** The audio tracks in this stream. */
    OHOSAudioTrackVector GetAudioTracks() override;
    /** The video tracks in this stream. */
    OHOSVideoTrackVector GetVideoTracks() override;
    /** find The audio tracks by track id. */
    rtc::scoped_refptr<OHOSAudioTrackInterface> FindAudioTrack(
        const std::string track_id) override;
    /** find The video tracks by track id. */
    rtc::scoped_refptr<OHOSVideoTrackInterface> FindVideoTrack(
        const std::string track_id) override;
    /** An identifier for this media stream. */
    const std::string stream_id() override {
      return stream_id_;
    }
    /**
     * MediaStreamInterface representation of this OHOSMediaStream object. This is
     * needed to pass to the underlying C++ APIs.
     */
    const rtc::scoped_refptr<webrtc::MediaStreamInterface> media_stream() override {
      return media_stream_;
    }

  private:
    rtc::scoped_refptr<webrtc::MediaStreamInterface> media_stream_;
    std::vector<rtc::scoped_refptr<OHOSAudioTrackInterface>> audio_tracks_;
    std::vector<rtc::scoped_refptr<OHOSVideoTrackInterface>> video_tracks_;
    std::string stream_id_;
    rtc::scoped_refptr<OHOSPeerConnectionFactoryInterface> peer_connection_factory_;
    rtc::Thread* signaling_thread_;
  };
}

#endif